package com.bosssoft.hr.javase;

import java.util.Arrays;

/**
 * @Description: TreeSetExample测试
 * @Author: WengYu
 * @CreateTime: 2022/05/16 21:51
 */
public class TreeSetExampleTest {
    public static void main(String[] args) {
        User user1 = new User(1, "wengyu1");
        User user2 = new User(2, "wengyu2");
        User user3 = new User(3, "wengyu3");

        TreeSetExample treeSetExample = new TreeSetExample();
        treeSetExample.add(user1);
        treeSetExample.add(user3);
        treeSetExample.add(user2);

        System.out.println("是否包含："+treeSetExample.contains(user1));
        System.out.println("删除元素并返回："+treeSetExample.remove(user1));
        System.out.println(Arrays.toString(treeSetExample.toArray()));

        User[] users = new User[]{new User(1,"wengyu1"),new User(3,"wengyu3"),new User(2,"wengyu2")};
        System.out.println("排序前----------------》");
        for (User user : users) {
            System.out.println(user);
        }

        System.out.println("排序后----------------》");
        User[] users1 = treeSetExample.sort(users);
        for (User user : users1) {
            System.out.println(user);
        }
    }
}
